﻿//using IO.Swagger.Api;
//using IO.Swagger.Client;
//using RestSharp;
using IO.Swagger.Api;
using IO.Swagger.Client;
using System.Net;
using System.Net.Security;

namespace Sapmple
{
    public class Program
    {
        private static void Main()
        {
            //#if DEBUG
            //            ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) =>
            //            {
            //                return true;
            //            };
            //#endif
            Configuration.X509Certificate2 = new System.Security.Cryptography.X509Certificates.X509Certificate2("certificate.pfx", "LANXIAOFANG");
            Configuration.DefaultApiClient = new ApiClient("https://172.18.64.150:65530/api");

            EncryptionMachineApi api = new EncryptionMachineApi();

            var password = api.EncryptionMachineEncryptPost(new IO.Swagger.Model.EncryptionMachineEncryptedModel()
            {
                Value = "admin"
            });

            AccountApi account = new AccountApi();

            var token = account.AccountSignInForeverPost(new IO.Swagger.Model.LoginUser()
            {
                UserName = "admin",
                Password = password.EncryptedValue
            });

            Configuration.DefaultApiClient.DefaultHeader.Add("Authorization", $"Bearer {token.Token}");

            PowderProcessApi powderProcessApi = new PowderProcessApi();

            var result= powderProcessApi.PowderProcessRecordPowderProcessCompletionPost(new IO.Swagger.Model.PowderProcessCompletion()
            {
                Site = 99999,
                DeviceId = "测试设备ID",
                Message = "测试工序完成",
                Variety = "测试品种",
                Material = "测试物料",
                Order = "测试工单",
                ProcessName = "测试工艺步骤",
                AlarmCount = 5000
            });

            if (result.IsSuccess == true)
            {
                System.Console.WriteLine("end.");
            }
        }
    }
}

